package com.bcu.calculus.controller;

import com.bcu.calculus.entity.Branch;
import com.bcu.calculus.entity.Message;
import com.bcu.calculus.entity.Remark;
import com.bcu.calculus.service.BranchService;
import com.bcu.calculus.service.RemarkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "17 党小组模块")
@RestController
@RequestMapping("/api/branch")
public class BranchController {

    @Resource
    private BranchService branchService;

    @ApiOperation(value = "添加党小组")
    @PostMapping(value = "/add")
    public Message<?> addBranch(Branch branch){
        return branchService.add(branch);
    }

    @ApiOperation(value = "删除党小组")
    @DeleteMapping(value = "/del")
    public Message<?> delBranch(Integer branchId){
        return branchService.del(branchId);
    }

    @ApiOperation(value = "修改党小组")
    @PutMapping(value = "/update")
    public Message<?> updateBranch(Branch branch){
        return branchService.update(branch);
    }

    @ApiOperation(value = "查找党小组")
    @GetMapping(value = "/getAll")
    public Message<List<Branch>> findAll(){
        return branchService.selectAll();
    }

    @ApiOperation(value = "通过主键查找党小组")
    @GetMapping(value = "/getByPK")
    public Message<Branch> findByPK(Integer branchId){
        return branchService.selectByPK(branchId);
    }

}
